package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Tcdetail;
import com.zjsd.sqeybusiness.service.ITcdetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 套餐明细Controller
 * 
 * @author Zheng
 * @date 2022-05-10
 */
@RestController
@RequestMapping("/sqeybusiness/tcdetail")
public class TcdetailController extends BaseController
{
    @Autowired
    private ITcdetailService tcdetailService;

    /**
     * 查询套餐明细列表
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:tcdetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(Tcdetail tcdetail)
    {
        startPage();
        List<Tcdetail> list = tcdetailService.selectTcdetailList(tcdetail);
        return getDataTable(list);
    }

    /**
     * 导出套餐明细列表
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:tcdetail:export')")
    //@Log(title = "套餐明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Tcdetail tcdetail)
    {
        List<Tcdetail> list = tcdetailService.selectTcdetailList(tcdetail);
        ExcelUtil<Tcdetail> util = new ExcelUtil<Tcdetail>(Tcdetail.class);
        return util.exportExcel(list, "tcdetail");
    }

    /**
     * 获取套餐明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:tcdetail:query')")
    @GetMapping(value = "/{detailid}")
    public AjaxResult getInfo(@PathVariable("detailid") Long detailid)
    {
        return AjaxResult.success(tcdetailService.selectTcdetailById(detailid));
    }

    /**
     * 新增套餐明细
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:tcdetail:add')")
    //@Log(title = "套餐明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tcdetail tcdetail)
    {
        return toAjax(tcdetailService.insertTcdetail(tcdetail));
    }

    /**
     * 修改套餐明细
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:tcdetail:edit')")
    //@Log(title = "套餐明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tcdetail tcdetail)
    {
        return toAjax(tcdetailService.updateTcdetail(tcdetail));
    }

    /**
     * 删除套餐明细
     */
    @PreAuthorize("@ss.hasPermi('sqeybusiness:tcdetail:remove')")
    //@Log(title = "套餐明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailids}")
    public AjaxResult remove(@PathVariable Long[] detailids)
    {
        return toAjax(tcdetailService.deleteTcdetailByIds(detailids));
    }
}
